extends Node

## 幻兽系统测试脚本
## 用于验证新的幻兽基础属性和成长率系统

func _ready():
	print("=== 幻兽系统测试开始 ===")
	test_phantom_beast_creation()
	test_phantom_beast_stats()
	print("=== 幻兽系统测试完成 ===")

func test_phantom_beast_creation():
	"""测试幻兽创建功能"""
	print("\n--- 测试幻兽创建 ---")
	
	# 模拟史莱姆怪物数据
	var slime_data = {
		"id": "slime",
		"name": "史莱姆",
		"max_hp": 60,
		"attack": 12,
		"defense": 3,
		"attack_speed": 80,
		"rarity": "common"
	}
	
	# 强制获得幻兽进行测试
	var success = PhantomBeastManager.try_obtain_phantom_beast(slime_data, true)
	if success:
		print("✓ 史莱姆幻兽创建成功")
		
		# 获取最新创建的幻兽
		var beast_ids = PhantomBeastManager.owned_phantom_beasts.keys()
		if beast_ids.size() > 0:
			var latest_beast_id = beast_ids[-1]
			var beast_data = PhantomBeastManager.owned_phantom_beasts[latest_beast_id]
			
			print("幻兽基础属性:")
			print("  血量: %d" % beast_data.base_hp)
			print("  攻击: %d" % beast_data.base_attack)
			print("  防御: %d" % beast_data.base_defense)
			print("  攻速: %d" % beast_data.attack_speed)
			
			# 验证基础属性是否来自配置而非怪物属性的80%
			var expected_hp_from_monster = int(slime_data.max_hp * 0.8)  # 48
			var actual_hp = beast_data.base_hp  # 应该是45（来自配置）
			
			if actual_hp != expected_hp_from_monster:
				print("✓ 幻兽基础属性已独立于怪物属性 (配置值: %d, 旧计算值: %d)" % [actual_hp, expected_hp_from_monster])
			else:
				print("✗ 幻兽基础属性仍依赖怪物属性")
	else:
		print("✗ 史莱姆幻兽创建失败")

func test_phantom_beast_stats():
	"""测试幻兽属性计算"""
	print("\n--- 测试幻兽属性计算 ---")
	
	# 获取一个幻兽进行测试
	var beast_ids = PhantomBeastManager.owned_phantom_beasts.keys()
	if beast_ids.size() == 0:
		print("✗ 没有幻兽可供测试")
		return
	
	var beast_id = beast_ids[0]
	var beast_data = PhantomBeastManager.owned_phantom_beasts[beast_id]
	
	print("测试幻兽: %s (类型: %s)" % [beast_data.name, beast_data.monster_type])
	
	# 测试1级属性
	var stats_lv1 = PhantomBeastManager.get_phantom_beast_stats(beast_id)
	print("1级属性:")
	print("  血量: %d" % stats_lv1.max_hp)
	print("  攻击: %d" % stats_lv1.attack)
	print("  防御: %d" % stats_lv1.defense)
	print("  攻速: %d" % stats_lv1.attack_speed)
	
	# 模拟升级到5级
	beast_data.level = 5
	var stats_lv5 = PhantomBeastManager.get_phantom_beast_stats(beast_id)
	print("5级属性:")
	print("  血量: %d" % stats_lv5.max_hp)
	print("  攻击: %d" % stats_lv5.attack)
	print("  防御: %d" % stats_lv5.defense)
	print("  攻速: %d" % stats_lv5.attack_speed)
	
	# 计算成长率
	var hp_growth = float(stats_lv5.max_hp - stats_lv1.max_hp) / stats_lv1.max_hp
	var attack_growth = float(stats_lv5.attack - stats_lv1.attack) / stats_lv1.attack
	print("4级成长:")
	print("  血量成长: %.1f%%" % (hp_growth * 100))
	print("  攻击成长: %.1f%%" % (attack_growth * 100))
	
	# 恢复等级
	beast_data.level = 1

func test_different_monsters():
	"""测试不同怪物的幻兽属性差异"""
	print("\n--- 测试不同怪物幻兽 ---")
	
	# 测试哥布林
	var goblin_data = {
		"id": "goblin",
		"name": "哥布林",
		"max_hp": 80,
		"attack": 18,
		"defense": 6,
		"attack_speed": 90,
		"rarity": "common"
	}
	
	PhantomBeastManager.try_obtain_phantom_beast(goblin_data, true)
	
	# 测试野狼
	var wolf_data = {
		"id": "wolf",
		"name": "野狼",
		"max_hp": 100,
		"attack": 22,
		"defense": 8,
		"attack_speed": 120,
		"rarity": "uncommon"
	}
	
	PhantomBeastManager.try_obtain_phantom_beast(wolf_data, true)
	
	print("已创建多种幻兽，可在幻兽界面查看属性差异")